<?php
class login extends spController
{
	function __construct(){ 
		parent::__construct();
		$this->caterows = spClass("article_list")->findAll("pid=49 and is_open=1","sort_id asc,id desc"); 
		session_start();
	}
	//调查列表
	function index(){

		$this->username11=$_SESSION["username"]; 
		
		$this->display("index/login.html");
	}
	
    function loginin(){
       	$username    = empty($_POST['username'])?"":$_POST['username'];
		$password   = empty($_POST['password'])?"":$_POST['password']; 
		$password=md5($password);
		
		$users    = spClass("member_list")->find("username='".$username."'"); 

		if(empty($users)){  
		    $this->error("用户名",spUrl("login","index"));
		 }
		else
		{
		     
		     $users11= spClass("member_list")->find("password='".$password."'"); 
		           if(empty($users11))
			        {
					   $this->error("密码错误",spUrl("login","index"));
			     	}
		             else
		           {
				      $_SESSION["username"]=$username;
					  $this->username11=$_SESSION["username"];
					  $this->error("登录成功",spUrl("login","index"));
		           } 
		}
		
	}
	
	//调查列表详细
	
   function loginout(){ 

		session_destroy();
		$this->jump(spUrl("main","index"));
	}
	function reg(){ 

		
		$this->display("index/regist.html");
	}
	//添加
	function addpage(){
		$username    = empty($_POST['username'])?"":$_POST['username'];
		$password   = empty($_POST['password'])?"":$_POST['password'];
		$email        = empty($_POST['email'])?"":$_POST['email'];
		$tel   = empty($_POST['tel'])?"":$_POST['tel'];
		$address = empty($_POST['address'])?"":$_POST['address'];
		//dump(spClass('ask_value'));
		$password=md5($password);
		
	   $newrow = array(
			'username'      => $username,
			'password'     => $password,
			'email'      => $email ,
			'tel' => $tel,
			'address' => $address,
			'addtime'    => time(),
		);
		
	if($row=spClass('member_list')->create($newrow)){	
				if(empty($row)){
					$this->error("提交失败",spUrl("login","reg"));
				}else{
					$this->error("您的信息已经提交",spUrl("login","index"));
				}
			}
		
	}
	
	
	
}	